/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoHttpTest.go			*/
/********************************************************/

package main

import (
	. "GoGlb"
	P "GoPro"
)

func main() {
	p := new(P.GoHttpReq)
	h :=	"GET /index.html?n=123 HTTP/1.1\r\n" +
		"Host: www.baidu.com\r\n" +
		"User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130109 Firefox/10.0.12\r\n" +
		"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" +
		"Accept-Language: en-us,en;q=0.5\r\n" +
		"Accept-Encoding: gzip, deflate\r\n" +
		"Connection: keep-alive\r\n" +
		"Cookie: BAIDUID=702D8E8E51B8D3D706397AFB1CAEAA0C:FG=1; H_PS_PSSID=6249_1457_5225_6583_6504_6478_4759_6017_6428_6453_6529_6503\r\n" +
		"Cache-Control: max-age=0\r\n" +
		"Referer: http://www.geotmt.com/\r\n" +
		"\r\n";
	GoPrint("%s", h)
	if nil == p.GoHttpReqParse([]byte(h)) {
		GoPrint("Method: %s\n", p.GoHttpReqMethod())
		GoPrint("Host: %s\n", p.GoHttpReqHost())
		GoPrint("Path: %s\n", p.GoHttpReqPath())
		GoPrint("Proto: %s\n", p.GoHttpReqProto())
		GoPrint("User-Agent: %s\n", p.GoHttpReqUsrAgent())
		GoPrint("Accept: %s\n", p.GoHttpReqAccept())
		GoPrint("Accept-Language: %s\n", p.GoHttpReqAcceptLanguage())
		GoPrint("Accept-Encoding: %s\n", p.GoHttpReqAcceptEncoding())
		GoPrint("Connection: %s\n", p.GoHttpReqConnection())
		GoPrint("Cache-Control: %s\n", p.GoHttpReqCacheControl())
		GoPrint("Referer: %s\n\n", p.GoHttpReqReferer())
		c := p.GoHttpReqCookies()
		for _, v := range c {
			GoPrint("%s\n", v)
		}
	} else {
		GoPrint("Failed to GoHttpReqParse\n")
	}
}
